<?php
/**
 * Created by PhpStorm.
 * User: jack Wang
 * Date: 2021/7/16
 * Time: 10:26
 */

class Admins_model extends Base_Model
{
    public function __construct()
    {
        parent::__construct();
        $this->load->database();
    }


    /*
     * 获取全部数据
     */
    public function findAll()
    {
        $query = $this->db->get('admins');
        return $query->result_array();
    }

    /*
     * 获取一条数据
     */
    public function findOne($id)
    {
        $this->db->where('id', $id);
        $this->db->select('*');
        $query = $this->db->get('admins');
        return $query->result();
    }

    /*
     * 新增一条数据
     */
    public function add($data){
        $res = $this->db->insert('admins',$data);
        return $res;
    }

    /*
     * 修改一条数据
     */
    public function dell($data){
        $this->db->where('id',$data['id']);
        return $this->db->update("admins",$data);
    }
    /*
     * 删除一条数据
     */
    public function del($id){
        $this->db->where('id',$id);
        return  $this->db->delete('admins');
    }
}